package com.mytest.provider.qz;

import com.mytest.provider.qz.service.TestService;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.Date;

/**
 *  * 定时任务业务处理类，我们继承QuartzJobBean
 *  * 重写executeInternal方法来实现具体的定时业务逻辑
 * @Author: llq
 * @Date: 2020/5/9
 */
public class SampleJob  {
//    extends QuartzJobBean
    @Autowired
    private TestService testService;

    /**
     * 重写executeInternal方法来实现具体的定时业务逻辑
     * @param jobExecutionContext
     */
//    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
/*        testService.test();
        //获取JobDetail中关联的数据
//        String msg = (String) context.getJobDetail().getJobDataMap().get("msg");
        System.out.println("    Hi! :" + jobExecutionContext.getJobDetail().getKey());*/


/*        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println("TestQuartz02----" + sdf.format(new Date()));*/

        /*JobDetail jobDetail = jobExecutionContext.getJobDetail();
        JobDataMap jobDataMap = jobDetail.getJobDataMap();*/

//        long username = jobDataMap.getLongValue("username");
//        System.out.println("username::"+jobDataMap.getString("username"));
//        LocalDateTime.parse(jobDataMap.getString("time"));


        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println("TestQuartz----" + sdf.format(new Date()));
        System.out.println("啊哈");
    }
}

